﻿namespace WeDonekRpc.Helper.UAParser
{
    public sealed class OS
    {
        /// <summary>
        /// Constructs an OS instance
        /// </summary>
        public OS ( string family, string major, string minor, string patch, string patchMinor )
        {
            this.Family = family;
            this.Major = major;
            this.Minor = minor;
            this.Patch = patch;
            this.PatchMinor = patchMinor;
        }

        /// <summary>
        /// The familiy of the OS
        /// </summary>
        public string Family { get; }
        /// <summary>
        /// The major version of the OS, if available
        /// </summary>
        public string Major { get; }
        /// <summary>
        /// The minor version of the OS, if available
        /// </summary>
        public string Minor { get; }
        /// <summary>
        /// The patch version of the OS, if available
        /// </summary>
        public string Patch { get; }
        /// <summary>
        /// The minor patch version of the OS, if available
        /// </summary>
        public string PatchMinor { get; }
        /// <summary>
        /// A readable description of the OS
        /// </summary>
        /// <returns></returns>
        public override string ToString ()
        {
            var version = VersionString.Format(this.Major, this.Minor, this.Patch, this.PatchMinor);
            return this.Family + ( !string.IsNullOrEmpty(version) ? " " + version : null );
        }
    }
}
